import {useRequest as useARequest} from 'ahooks';
import type {
  Options,
  Plugin,
  Result,
  Service,
} from 'ahooks/lib/useRequest/src/types';

/**
 * 自定义请求 Hook
 *
 * @template TData 响应数据类型
 * @template TParams 请求参数类型
 * @param {Service<TData, TParams>} service 请求服务函数
 * @param {Options<TData, TParams>} [options] 请求配置选项
 * @param {Plugin<TData, TParams>[]} [plugins] 插件数组
 * @returns {Result<TData, TParams>} 请求结果对象
 */
export function useRequest<TData, TParams extends any[]>(
  service: Service<TData, TParams>,
  options?: Options<TData, TParams>,
  plugins?: Plugin<TData, TParams>[],
): Result<TData, TParams> {
  const result = useARequest<TData, TParams>(service, options, plugins);
  return result;
}

export default useRequest;
